/*
* 创建线程的方法: 2.实现Runnable接口 重写run
* */

/*
* Runnable 表示是一个可以运行的任务,至于这个任务是交给线程还是什么别的东西执行,runnable本身并不关心
* */
class MyRunnable implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("Hello Thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        MyRunnable runnable = new MyRunnable();
        Thread t = new Thread(runnable);
        t.start();

        while(true){
            System.out.println("main");
            Thread.sleep(1000);
        }
    }
}
